package com.asset.dispoal.interestFormula;

import com.asset.dispoal.interestFormula.api.InterestFormulaService;
import com.asset.dispoal.interestFormula.dto.InterestFormulaRequest;
import com.asset.dispoal.interestFormula.dto.InterestFormulaResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import tech.mhuang.pacebox.springboot.core.permission.annotation.Permission;
import tech.mhuang.pacebox.springboot.protocol.Result;
import tech.mhuang.pacebox.springboot.protocol.data.PageVO;

/**
 * @author qr
 * @date 2022/3/28$
 */
@RestController
@Api(value = "预期公式管理", tags = "预期公式管理")
@RequestMapping("system/interestFormula")
public class InterestFormulaController {


    @Autowired
    InterestFormulaService interestFormulaService;


    @Permission(code = "publicConfigFormula:add")
    @PostMapping("insert")
    @ApiOperation(value = "添加")
    public Result insert(@RequestBody InterestFormulaRequest request) {
        interestFormulaService.insert(request);
        return Result.ok();
    }

    @Permission(code = "publicConfigFormula:update")
    @PostMapping("update")
    @ApiOperation(value = "修改")
    public Result update(@RequestBody InterestFormulaRequest request) {
        interestFormulaService.update(request);
        return Result.ok();
    }

    @Permission(code = "publicConfigFormula:del")
    @PostMapping("delete")
    @ApiOperation(value = "删除")
    public Result delete(@RequestBody String id) {
        interestFormulaService.delete(id);
        return Result.ok();
    }

    @Permission(code = "publicConfigFormula")
    @GetMapping("queryPage")
    @ApiOperation(value = "分页查询")
    public Result<PageVO<InterestFormulaResponse>> queryPage(InterestFormulaRequest request) {
        return interestFormulaService.queryPage(request);
    }

}
